<template>
	<view class="u-tabs">
		<view class="u-icon-box " v-for="(item, index) in tabs" :key="index" :class="{'selectedTab': selTab==index}"
			@tap="swichTabs(index, item.id)">
			<image :src="ossUrl + item.categoryIcon"></image>
			<tui-text :text="item.categoryName" size="30" fontWeight="600"></tui-text>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'tutorStoreShort',
		emits: ['change'],
		props: {
			// 分类数据列表
			tabs: {
				type: Array,
				default: []
			},
			//oss
			ossUrl:{
				type: String,
				default:''
			}
		},
		data() {
			return {
				selTab: 0
			};
		},
		methods: {
			// 点击标题切换当前页时改变样式
			swichTabs: function(index, id) {
				if (this.currentTab == index) {
					return false;
				} else {
					this.selTab = index;
					this.selCategoryId = id;
					this.$emit('change', {
						index: Number(index),
						categoryId: id
					});
				}
			}
		}
	};
</script>

<style>
	.u-tabs {
		width: 100%;
		display: flex;
		justify-content: space-between;
		background-color: #f5f5f5
	}

	.u-tabs .u-icon-box {
		width: 160rpx;
		height: 160rpx;
		border-radius: 20rpx;
		background-color: #eee;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}

	.u-tabs .u-icon-box image {
		display: block;
		width: 60rpx;
		height: 60rpx;
	}

	.selectedTab {
		height: 171rpx !important;
		background: transparent url("");
		background-size: 100% 100%;
	}
</style>